<%@page import="java.util.ArrayList"%>
<%@page import="database.ProductDAO"%>
<%@page import="model.Category"%>
<%@page import="java.util.List"%>
<%@page import="model.Role"%>
<%@page import="model.Staff"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<%
    Staff staff = (Staff) session.getAttribute("staff");

    if (staff == null) {
        response.sendRedirect(request.getContextPath() + "/Administration");
    } else if (!staff.getRoleList().contains(new Role(2))) {
        response.sendRedirect(request.getContextPath() + "/Administration/home");
    } else {
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Add Product</title>
          <link href="<%= request.getContextPath()%>/css/style_for_page.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/style_for_menu.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/style_addtion.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/style_for_warehousing.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/adMenu.css" rel="stylesheet" type="text/css"/>
        <link href="<%= request.getContextPath()%>/css/tHeaderFooter.css" rel="stylesheet" type="text/css"/>
    </head>
     <body style="background-color: lightsteelblue;">
         <div class="headerbg">
            <div class="header"> 
                <%@include file="/include/mHeader.jsp" %>
            </div>
            <div class="adContent">
                <div class="adMenu">
                    <%@include file="/include/mMenu.jsp" %>
                </div>
            </div>
        </div>
        <div class="contentbg">
                <div class="content" style="border-bottom:  1px black dashed; ">
                    <div class="registerForm">
                        <h1>Product Image:</h1>
                        <p><%= request.getContextPath()%>/image/<s:property value="userImageFileName"/></p>
                        <br/>         
                        <img src="<%= request.getContextPath()%>/image/<s:property value="userImageFileName"/>" width="150" height="150"/> 
                    </div>
                    <div class="registerTerms">
                        <h1>Product Information</h1>   
                        <s:form action="addProduct" namespace="/Administration/Product"> 
                        <s:textfield name="name" label="Product Name" size="30" />
                        <s:textfield name="details" label="Product Detail" size="30" />
                        <s:textfield name="brand" label="Product Brand" size="30" />
                        <s:textfield name="others" label="Other Information" size="30" />
                        <s:textfield name="summary" label="Product Summary" size="30" />
                        <s:textfield name="unitPrice" label="Unit Price" size="30" />
                        <s:textfield name="sale" label="Sale Price" size="30" />
                        <s:textfield name="stockQuantity" label="Stock Quantity" size="30" />
                        <s:select label="Select category" 
                                  list="allCategory" 
                                  name="idCategory" cssStyle="width: 200px"/>
                        <s:hidden name="imageurl"/>

                        <table>
                            <tr>
                                <td>
                                    <s:reset value="Reset" cssStyle="width: 96px" theme="simple" />
                                </td>
                                <td>
                                    <s:submit  value="Add Product" cssStyle="width: 96px; margin-left: 132px" theme="simple" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2"><s:actionerror /></td>
                            </tr>
                        </table>
                             </s:form>
                    </div>
                </div>
           
        </div>  
        <footer>
            <div id="footer">
                <%@include file="/include/iFooter.jsp" %>
            </div>   
        </footer>

    </body>
</html>
<%
    }
%>